//------------------------------------------------cookie------------------------------------------------
export function getCookie(cname)         //获取cookie
{
  var name = cname + "=";
  var ca = document.cookie.split(';');
  for(var i=0; i<ca.length; i++) 
  {
    var c = ca[i].trim();
    if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }
  return "";
}


export function removeCookie(cname)   //移除cookie
{
    document.cookie = cname+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
}

//------------------------------------------------数据生成Excel表格------------------------------------------------


export function creatExcelFn(cname,data)   
{
  let blob=new Blob([data])   //数据转格式
  let downloadElement=document.createElement("a")  //创建a标签
  let href=window.URL.createObjectURL(blob)   // 创建数据下载链接
  downloadElement.href=href
  downloadElement.download=cname       //cname下载的文件名
  document.body.appendChild(downloadElement)  
  downloadElement.click()  //点击下载
  document.body.removeChild(downloadElement)  //移除下载元素
  window.URL.revokeObjectURL(href)  //释放掉blob对象
}
